<template>
 <el-container>
        <el-header>喵喵网管理后台 ，欢迎：{{ $store.state.user.name }}</el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu default-active="1">
                    <el-menu-item index="1">
                        <i class="el-icon-menu"></i>
                        <router-link to="/admin/users" tag="span" slot="title">用户管理</router-link>
                    </el-menu-item>
                    <el-menu-item index="2">
                        <i class="el-icon-document"></i>
                        <router-link to="/admin/movie" tag="span" slot="title">电影管理</router-link>
                    </el-menu-item>
                    <el-menu-item index="3">
                        <i class="el-icon-setting"></i>
                        <router-link to="/admin/cinema" tag="span" slot="title">影院管理</router-link>
                    </el-menu-item>
                </el-menu>    
            </el-aside>
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
import axios from "axios";
export default {
    name:"Admin",
    //进入这个路由之前进行登录态的验证 灭有登录就返回登录页面 有级继续保存
    // 等于0的话那就是管理员   如果不是那就跳转到登录界面 如果是就放行
    beforeRouteEnter(to, from, next) {
      //这里就不在封装一层了 直接调用
      // getuser().then(res=>{
      //      //接口失效无法打印
      //     var status = res.status;
      //     if(status === 0) {
      //   next(vm =>{vm.$store.commit('User/USER_NAME',{name:res.data.username})})
      //     }else {
      //       next('/mine/login')
      //     }
      // })
    //    axios.get("/api2/admin").then((res) => {
      var status = 0;
          if (status === 0) {
           next();
         } else {
          next('/mine/login');
      }
    // });
},
}
</script>

<style scoped>
.el-header, .el-footer {
background-color: #B3C0D1;
color: #333;
padding-left:60px;
line-height: 60px;
}

.el-aside {
background-color: #D3DCE6;
color: #333;
text-align: center;
line-height: 200px;
}

.el-main {
background-color: #E9EEF3;
color: #333;
text-align: center;
}

body > .el-container {
margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
line-height: 320px;
}
</style>
